<!DOCTYPE html>
<html>

{include file='public/header'}
<style>
    .layui-input-block {
        margin-left: 0px;
    }
</style>

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">版权合作</a>
            <a><cite>合作方统计</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <!-- <div class="layui-inline" style="display: inline-flex;">
                    <label class="layui-form-label">
                        <span class="x-red">*</span>选择短剧
                    </label>
                    <div id="pVideo" style="width: 100%;flex: 1;"></div>
                </div> -->
                <div class="layui-inline" style="display: inline-flex;">
                    <label class="layui-form-label w-auto">选择短剧：</label>
                    <div id="pVideo" style="width:100%;flex:1"></div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">提交时间：</label>
                    <div class="layui-inline" id="time" style="display: flex;align-items: center;">
                        <div class="layui-input-inline" style="margin-right:10px">
                            <input type="text" autocomplete="off" name="start_date" id="start_date" class="layui-input"
                                placeholder="开始日期">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" name="end_date" id="end_date" class="layui-input"
                                placeholder="结束日期">
                        </div>
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="cooperaterCountList" lay-filter="cooperaterCountList"></table>
    </div>
    <script>
        let dayTime = dayjsFormat(new Date().getTime()/1000,false);
        let lastTime = dayjsFormat((new Date().getTime() - (30 * 24 * 60 * 60 * 1000))/1000,false);
        var self_amount,total_amount;
        let params = {
            elem: '#cooperaterCountList'
            , url: '/admin/partnersNew/cooperaterCountList' //数据接口
            , id: 'cooperaterCountList'
            , page: true
            , totalRow:true
            , where:{
                start_date:lastTime,
                end_date:dayTime,
            }
            , limit:15
            , cols: [[ //表头
                { field: 'date', title: '时间', align:'center', totalRowText: '合计：'}
                , { field: 'video_name', title: '剧名', align:'center' }
                , { field: 'total_price', title: '总充值金额', align:'center' }
                , { field: 'self_price', title: '自投充值金额', align:'center' }
            ]]
            , parseData:function (res) { //res 即为原始返回的数据
                self_amount = res.data.self_amount
                total_amount = res.data.total_amount
                if(res.code == 200){
                    return {
                        "data": res.data?.data,
                        "code": res.code,
                        'count': res.data?.total
                    }
                }else{
                    return {
                        "data": [],
                        "code": 200,
                        'count':0
                    };
                }
            }
            , done: function (res, curr, count) {
                console.log(res, curr, count)
                this.elem.next().find('.layui-table-total td[data-field="total_price"] .layui-table-cell').text(total_amount);
                this.elem.next().find('.layui-table-total td[data-field="self_price"] .layui-table-cell').text(self_amount);
            }
        }
        tableList(params)
        
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            //日期范围
            laydate.render({
                elem: '#time'
                , range: ['#start_date', '#end_date']
                , format: 'yyyy-MM-dd',
                value: [lastTime,dayTime]
            });
        })

        let xmSelectVideoOption = {
            url:'/admin/partnersNew/selectVideoNameList?type=2',
            selected: [],
            tips: '选择短剧',
            name: 'video_id',
            field_id: 'id',
            field_Name: 'name',
            elem: '#pVideo'
        }
        selectN(xmSelectVideoOption)
    </script>
</body>

</html>